package edu.hawaii.duedates;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.fail;

import org.junit.Test;

/**
 * Test case for command line arguments being passed by a user via command prompt.
 * 
 * @author Anthony M. Du
 */

public class TestArguments {

  /**
   * Test situation if arguments are fully provided.
   */
  @Test
  public void testNormalOperation() {
    String[] args = {"arg1", "arg2", "arg3", "arg4"};
    assertEquals("Testing first argument", "arg1", args[0]);
    assertEquals("Testing second argument", "arg2", args[1]);
    assertEquals("Testing third argument", "arg3", args[2]);
    assertEquals("Testing fourth argument", "arg4", args[3]);
    assertEquals("Testing length of arguments", 4, args.length);
  }

  /** 
   * Test illegal argument access exception.
   * 
   *  @exception ArrayIndexOutOfBoundsException If errors during argument processing.
   * */
  @Test(expected = ArrayIndexOutOfBoundsException.class)
  public void testIllegalArgumentCall() throws ArrayIndexOutOfBoundsException {
    String[] args = {};
    System.out.println(args[0]);
    fail("Illegal argument call did not throw an exception");
  }

  /**
   * Test situation if argument list is null.
   */
  @Test
  public void testNullParams() {
    String[] args = null;
    assertSame("Testing null argument", null, args);
  }

}
